<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>百度贴吧管理系统——贴吧列表</title>
<!-- zui -->
<link href="../zui/dist/css/zui.min.css" rel="stylesheet">
<script type="text/javascript" src="../js/user/tiebas.js"></script>
<link href="../img/favicon.ico" rel="shortcut icon" type="image/x-icon" />
</head>
<body>
	<div class="row">
		<div class="col-md-2"></div>
		<div class="col-md-8">
			<a href="../jsp/index.jsp"><img src="../img/logo.gif" class="img-responsive"></a>
		</div>
		<div class="col-md-2"></div>
	</div>

	<div class="row">
		<div class="col-md-2"></div>
		<div class="col-md-8">
			<nav class="navbar navbar-default" role="navigation">
				<ul class="nav navbar-nav nav-justified">
					<li><a href="../jsp/index.jsp">首页</a></li>					
					<li><a href="../tieba/listUserAction">用户列表</a></li>
					<li class="active" onclick="location.reload(true)"><a href="">贴吧列表</a></li>
					<li><a href="../post/listPostAction">帖子列表</a></li>
				</ul>
			</nav>
		</div>
		<div class="col-md-2"></div>
	</div>

	<div class="row">
		<div class="col-md-2"></div>
		<div class="col-md-8">
			<table class="table datatable">
				<thead>
					<tr>
						<th><i class="icon icon-user"></i> 用户名</th>
						<th><button onclick="addUser()"
								class="btn btn-sm btn-success">添加新用户</button>
					</tr>
				</thead>
				<tbody>
					<s:iterator id="userList" value="userList">
						<tr>
							<td><s:property value='#userList.getUserName()' /></td>
							<td>
								<form class="pull-left" method="post"
									action="showUsersTiebasAndPostsAction">
									<input class="hide" type="text" name="userName"
										value="<s:property value='#userList.getUserName()' />" /><input
										class="hide" type="text" name="userPassword"
										value="<s:property value='#userList.getUserPassword()' />" />
									<input class="hide" type="text" name="userSex"
										value="<s:property value='#userList.getUserSex()' />" /><input
										class="hide" type="text" name="userBirthday"
										value="<s:property value='#userList.getUserBirthday()' />" />
									<button type="submit" class="btn btn-sm btn-primary pull-left">查看</button>
								</form>
								<form class="pull-left" method="post" action="deleteUserAction"
									style="float: right;">
									<div class="pull-left">&nbsp;</div>
									<button type="submit" class="btn btn-sm btn-danger pull-left">删除</button>
									<input class="hide" type="text" name="userName"
										value="<s:property value='#userList.getUserName()' />" />
								</form>

							</td>
						</tr>
					</s:iterator>
				</tbody>
			</table>
		</div>
		<div class="col-md-2"></div>
	</div>

	<div class="row">
		<div class="col-md-2"></div>
		<div class="col-md-8">
			<ul class="pager pager-loose">
				<%
				    int pageCount = Integer.parseInt(request.getAttribute("pageCount")
				            .toString());
				    int pageNow = Integer.parseInt(request.getAttribute("pageNow")
				            .toString());
				%>
				<li><a href="../user/listUserAction?pageNow=1">首页</a></li>
				<li class="previous"><a
					href="../user/listUserAction?pageNow=
                    <%if (pageNow <= 1) {
                out.print(1);
            } else
                out.print(pageNow - 1);%>">«
						上一页</a></li>
				<%
				    for (int i = 1; i <= pageCount; i++) {
				        if (pageNow == i) {
				            out.print("<li class='active'><a href='../user/listUserAction?pageNow="
				                    + i + "'>" + i + "</a></li>");
				        } else {
				            out.print("<li><a href='../user/listUserAction?pageNow="
				                    + i + "'>" + i + "</a></li>");
				        }
				    }
				%>
				<li class="next"><a
					href="../user/listUserAction?pageNow=
                    <%if (pageNow >= pageCount) {
                out.print(pageCount);
            } else
                out.print(pageNow + 1);%>
                    ">下一页
						»</a></li>
				<li><a href="../user/listUserAction?pageNow=${pageCount}">尾页</a></li>
			</ul>
		</div>
		<div class="col-md-2"></div>
	</div>

	<!-- jQuery (ZUI中的Javascript组件依赖于jQuery) -->
	<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
	<!-- ZUI Javascript组件 -->
	<script src="../zui/dist/js/zui.min.js"></script>
</body>
</html>